package com.hsnn.medstgmini.sys.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.commons.lang.StringUtils;

import com.hsnn.medstgmini.model.Status;

/**
 * @category 角色
 * @author 蔡春龙
 * @date 2015年6月12日
 */
@Entity
@Table(name = "sys_role")
public class SysRole implements Serializable {

	private static final long serialVersionUID = 1L;

	private String id;//角色id
	private String name;//角色名称
	private String pid;//父级角色id
	private Integer main;//是否是主角色(0：否，1：是)
	private String fatherName;//
	private Integer type;//子角色类型（0：系统级，1：非系统级）
	private String typeName;
	private Integer level;//角色级别
	private Integer sort = 0;//角色顺序
	private String boundId;//企业、医疗机构id(子角色类型为自定义时生效)
	private Integer status;//状态1.启用0停用
	private String statusName;
	private String createUserId;//创建人
	private Date createDateTime;//创建时间
	private String updUser;//修改人
	private Date updDateTime;//修改时间
	private String remark;//备注

	@Id
	@Column(name = "id")
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@Column(name = "name")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "pid")
	public String getPid() {
		if (StringUtils.isBlank(pid)) {
			pid = "0";
		}
		return pid;
	}

	public void setPid(String pid) {
		this.pid = pid;
	}

	@Transient
	public String getFatherName() {
		return fatherName;
	}

	public void setFatherName(String fatherName) {
		this.fatherName = fatherName;
	}

	@Column(name = "main")
	public Integer getMain() {
		return main;
	}

	public void setMain(Integer main) {
		this.main = main;
	}

	@Column(name = "type")
	public Integer getType() {
		return type;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	@Transient
	public String getTypeName() {
		if (type != null) {
			typeName = RoleType.getName(type);
		}
		return typeName;
	}

	public void setTypeName(String typeName) {
		this.typeName = typeName;
	}
	
	@Column(name = "level",length=1 )
	public Integer getLevel() {
		return level;
	}

	public void setLevel(Integer level) {
		this.level = level;
	}

	@Column(name = "sort")
	public Integer getSort() {
		return sort;
	}

	public void setSort(Integer sort) {
		this.sort = sort;
	}

	@Column(name = "bound_id")
	public String getBoundId() {
		return boundId;
	}

	public void setBoundId(String boundId) {
		this.boundId = boundId;
	}

	@Column(name = "status")
	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	@Transient
	public String getStatusName() {
		if (status != null) {
			statusName = Status.getName(status);
		}
		return statusName;
	}

	public void setStatusName(String statusName) {
		this.statusName = statusName;
	}

	@Column(name = "create_user_id")
	public String getCreateUserId() {
		return createUserId;
	}

	public void setCreateUserId(String createUserId) {
		this.createUserId = createUserId;
	}

	@Column(name = "create_datetime")
	public Date getCreateDateTime() {
		return createDateTime;
	}

	public void setCreateDateTime(Date createDateTime) {
		this.createDateTime = createDateTime;
	}

	@Column(name = "upd_datetime")
	public Date getUpdDateTime() {
		return updDateTime;
	}

	public void setUpdDateTime(Date updDateTime) {
		this.updDateTime = updDateTime;
	}

	@Column(name = "upd_user")
	public String getUpdUser() {
		return updUser;
	}

	public void setUpdUser(String updUser) {
		this.updUser = updUser;
	}

	@Column(name = "remark")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

}
